package com.gxa.service.gouhuoservice.Impl;

import com.gxa.common.R;
import com.gxa.mapper.gouhuomapper.GouHuoDan46Mapper;
import com.gxa.pojo.GouHuo;
import com.gxa.pojo.GouHuoShangPin;
import com.gxa.service.gouhuoservice.GouHuoDan46Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class GouHuoDan46ImplService implements GouHuoDan46Service {

    @Autowired
    private GouHuoDan46Mapper gouHuoDan46Mapper;

    @Override
    public R selectAllGouHuoDanForPage(int page, int size) {

        //分页
        int index=(page-1)*size;
        R r = new R();
        List <GouHuo>  gouHuos = gouHuoDan46Mapper.selectAllGouHuoDanForPage(index,size);
        if (gouHuos != null){
            r.setCode(200);
            r.setMsg("查询成功！");
            r.setData(gouHuos);
        }
        return r;
    }

    @Override
    public R selectAllGouHuoDan(int page, int size,  java.util.Date danJuRiQi,
                                int shenHeZhuangTai, String danJuBianHao,  String beiZhu) {

        int index=(page-1)*size;
        R r = new R();
        List <GouHuo>  gouHuos = gouHuoDan46Mapper.selectAllGouHuoDan(index,size,
                danJuRiQi,shenHeZhuangTai,  danJuBianHao, beiZhu);
        r.setCode(200);
        r.setMsg("查询成功！");
        r.setData(gouHuos);
        return r;
    }

    @Override
    public R deleteGouHuoById(int id) {
            R r = new R();
            int res = gouHuoDan46Mapper.deleteGouHuoById(id);
            r.setCode(500);
            r.setMsg("删除失败");
            if(res>0)
            {
                r.setCode(200);
                r.setMsg("删除成功");
            }
            return r;
    }

    @Override
    public R insertGouHuoDan(GouHuo gouHuo) {
        R r= new R();
        int res = gouHuoDan46Mapper.insertGouHuoDan(gouHuo);
        r.setCode(500);
        r.setMsg("新增失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("新增成功");
        }
        return r;
    }

    @Override
    public R ShenHeGouHuoDan(int shenHeZhuangTai) {
        R r = new R();
        int res = gouHuoDan46Mapper.ShenHeGouHuoDan(shenHeZhuangTai);
        r.setCode(500);
        r.setMsg("审核失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("审核成功");
        }
        return r;
    }


    @Override
    public R ShenHeGouHuoDanJiLu(int shenHeZhuangTai) {
        R r = new R();
        int res = gouHuoDan46Mapper.ShenHeGouHuoDanJiLu(shenHeZhuangTai);
        r.setCode(500);
        r.setMsg("审核失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("审核成功");
        }
        return r;
    }

    @Override
    public R ShenHeGouHuoDanJiLuFan(int shenHeZhuangTai) {
        R r = new R();
        int res = gouHuoDan46Mapper.ShenHeGouHuoDanJiLuFan(shenHeZhuangTai);
        r.setCode(500);
        r.setMsg("审核失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("审核成功");
        }
        return r;
    }
}



//    @Override
//    public R selectAllGouHuoDan(int page, int size, String gongYinShangId, String jieSuanZhangHuId,
//                                Date danJuRiQi, int shenHeZhuangTai, String danJuBianHao,
//                                float zongJinE, String beiZhu, float benCiFuKuan, int yeWuTypeId) {
//        R r = new R();
//        List <GouHuo>  gouHuos = gouHuoDan46Mapper.selectAllGouHuoDan(page,size,gongYinShangId,jieSuanZhangHuId,
//                                                                  danJuRiQi,shenHeZhuangTai,  danJuBianHao,
//                                                                         zongJinE, beiZhu,benCiFuKuan,yeWuTypeId);
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        r.setData(gouHuos);
//        return r;
//    }


